package com.cy.pj.sys.controller;

import com.cy.pj.common.pojo.JsonResult;
import com.cy.pj.sys.pojo.SysGoodsType;
import com.cy.pj.sys.service.SysTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/type/")
public class SysTypeController {

    @Autowired
    private SysTypeService sysTypeService;

    @RequestMapping("doUpdateObject")
    public JsonResult doUpdateObject(SysGoodsType sysGoodsType){
        sysTypeService.updateObject(sysGoodsType);
        return new JsonResult("修改成功");
    }

    @RequestMapping("doFindObjectById")
    public JsonResult doFindObjectById(Integer id){
        return new  JsonResult(sysTypeService.findObjectById(id));
    }

    @RequestMapping("doSaveObject")
    public JsonResult doSaveObject(String typeName){
        sysTypeService.insertObject(typeName);
        return new JsonResult("添加成功");
    }

    @RequestMapping("doDeleteById")
    public JsonResult doDeleteById(Integer id){
        return new JsonResult("禁止自行删除,请联系管理员");
    }

    @RequestMapping("doFindPageObjects")
    public JsonResult doFindPageObjects(String typename,Integer pageCurrent) {
        return new JsonResult(sysTypeService.findPageObjects(typename, pageCurrent));
    }
}
